package com.jvtd.eyl.bean.binding;

import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.os.Parcel;
import android.os.Parcelable;

import com.jvtd.eyl.BR;

/**
 * 分类实体
 *
 * 作者:chenlei
 * 时间:2018/11/12 4:38 PM
 */
public class ClassBean extends BaseObservable implements Parcelable {
    private String id;//分类ID
    private String name;//分类名称
    private String img;//分类图片
    private boolean isSelected;//是否选择

    @Bindable
    public boolean isSelected() {
        return isSelected;
    }

    public void setSelected(boolean selected) {
        isSelected = selected;
        notifyPropertyChanged(BR.selected);
    }

    @Bindable
    public String getId()
    {
        return id;
    }

    public void setId(String id)
    {
        this.id = id;
        notifyPropertyChanged(BR.id);
    }

    @Bindable
    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
        notifyPropertyChanged(BR.name);
    }

    @Bindable
    public String getImg()
    {
        return img;
    }

    public void setImg(String img)
    {
        this.img = img;
        notifyPropertyChanged(BR.img);
    }

    @Override
    public String toString() {
        return "ClassBean{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", img='" + img + '\'' +
                ", isSelected=" + isSelected +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.name);
        dest.writeString(this.img);
        dest.writeByte(this.isSelected ? (byte) 1 : (byte) 0);
    }

    public ClassBean() {
    }

    protected ClassBean(Parcel in) {
        this.id = in.readString();
        this.name = in.readString();
        this.img = in.readString();
        this.isSelected = in.readByte() != 0;
    }

    public static final Parcelable.Creator<ClassBean> CREATOR = new Parcelable.Creator<ClassBean>() {
        @Override
        public ClassBean createFromParcel(Parcel source) {
            return new ClassBean(source);
        }

        @Override
        public ClassBean[] newArray(int size) {
            return new ClassBean[size];
        }
    };
}
